package com.tjetc.view.impl;

import com.tjetc.constant.CommonConstant;
import com.tjetc.context.BaseContext;
import com.tjetc.controller.UserController;
import com.tjetc.exception.MessageException;
import com.tjetc.utils.ScannerUtils;
import com.tjetc.view.*;

/**
 * @Author: itda
 * @Date: 2024/5/9 13:29
 * @Description: UserPageImpl
 */
public class UserPageImpl implements UserPage {

    private UserController userController = new UserController();

    private UserLoginPage userLoginPage = new UserLoginPageImpl();

    private RegisterPage registerPage = new RegisterPageImpl();

    private CommonPage commonPage = new CommonPageImpl();

    private BookingCRUDPage bookingCRUDPage = new BookingCRUDPageImpl();

    @Override
    public void show() {
        while (true) {
            System.out.println("用户页面");
            System.out.println("1.登录");
            System.out.println("2.注册");
            System.out.println("3.浏览酒店");
            System.out.println("4.预订房间");
            System.out.println("5.取消预订");
            System.out.println("6.评价");
            System.out.println("7.历史订单");
            System.out.println("8.返回");
            switch (ScannerUtils.sc.nextInt()) {
                case 1:
                    userController.login(userLoginPage.login());
                    break;
                case 2:
                    userController.register(registerPage.register());
                    break;
                case 3:
                    userController.browse(commonPage.getByHotelId());
                    break;
                case 4:
                    userController.checkInRoom();
                    break;
                case 5:
                    userController.checkOutRoom();
                    break;
                case 6:
                    userController.comment(commonPage.getByHotelId());
                    break;
                case 7:
                    userController.historicalOrders();
                    break;
                case 8:
                    BaseContext.removeCurrentId();
                    return;
                default:
                    try {
                        throw new MessageException(CommonConstant.COMMAND_ERROR);
                    } catch (MessageException e) {
                        System.out.println(e.getMessage());
                    }
                    break;
            }
        }
    }
}
